package strdemo

import (
	"fmt"
	"time"
	"unsafe"
)

type Set map[string]struct{}

func (s Set) Has(key string) bool {
	_, ok := s[key]
	return ok
}

func (s Set) Add(key string) {
	s[key] = struct{}{}
}

func (s Set) Delete(key string) {
	delete(s, key)
}

func worker(ch chan struct{}) {
	//读阻塞
	<-ch
	fmt.Println("do something")
	close(ch)
}

func create() {
	slice := make([]int, 10)
	fmt.Println(slice)
	fmt.Println(unsafe.Sizeof(slice))
	fmt.Println(len(slice))

	hash := make(map[string]bool, 10)
	fmt.Println(hash)

	i := new(int)
	fmt.Println(&i)
	time.Sleep(time.Second * 2)
}
